<?php
class BaseAction extends Action {
	public $openid;
    public $sdk;
	public $user_info;
	function _initialize() {
	      $this->sdk = new OpenApiV3(C('appid'), C('appkey'));
          $this->sdk->setServerName(C('server_name'));
          $_SESSION['openid']=isset($_GET['openid'])?$_GET['openid']:$_SESSION['openid']; 
	      $_SESSION['openkey']=isset($_GET['openkey'])?$_GET['openkey']:$_SESSION['openkey'];	
          $this->openid=$_SESSION['openid'];
		  //获取用户基本资料
		//  $this->user_info=$this->get_user_info($this->sdk, C('openid'), C('openkey'), C('pf'));
		    $this->user_info=$this->get_user_info($this->sdk, $_SESSION['openid'],  $_SESSION['openkey'], C('pf'));
	}
	function get_user_info($sdk, $openid, $openkey, $pf)
   {
	$params = array(
		'openid' => $openid,
		'openkey' => $openkey,
		'pf' => $pf,
	);
	
	$script_name = '/v3/user/get_info';
    return $sdk->api($script_name, $params,'post');	
    }
}